﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FB.Utilities;
using System.Web.Security;

namespace FB.admin
{
    public partial class Admin : System.Web.UI.MasterPage
    {
        /// <summary>
        ///  View State CurrentUser
        /// </summary>
        public string CurrentUser
        {
            get
            {
                object obj = this.ViewState["_CurrentUser"];
                if (obj == null)
                    return ""; //default to show ID : 0 
                else
                    return (string)obj;
            }
            set
            {
                this.ViewState["_CurrentUser"] = value;
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CheckPermission();
            }
        }

        private void CheckPermission()
        {
            if (Page.User.IsInRole(Constants.ROLE_ADMINISTRATOR)
                || Page.User.IsInRole(Constants.ROLE_AUTHOR)
                || Page.User.IsInRole(Constants.ROLE_CONTRIBUTER)
                || Page.User.IsInRole(Constants.ROLE_EDITOR))
            {
                //
            }
            else
            {
                Response.Redirect("/admin/AccessDenied.aspx");
            }
        }
    }
}